import cn.laixueit.pojo.Game;
import cn.laixueit.service.GameService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:spring.xml"})
public class Demo {

    @Autowired
    private GameService gameService;

    @Test
    public void all(){
        List<Game> gameList = gameService.list();
        System.out.println(gameList);
    }

    @Test
    public void save(){
        ArrayList<Game> games = new ArrayList<>();
        for (int i = 0; i < 100; i++) {
            Game game = new Game();
            game.setName("藏"+i);
            game.setCreatetime(new Date());
            games.add(game);
        }
        boolean b = gameService.saveBatch(games);
    }

    @Test
    public void del(){
        ArrayList<Integer> ids = new ArrayList<>();
        for (int i = 2; i < 104; i++) {
            ids.add(i);
        }
        gameService.removeByIds(ids);
    }
}
